package com.utf999.qiangmanger.utils;

import java.io.UnsupportedEncodingException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * mysql数据库中文进行编码转换
 * @author lc
 *
 */
public class EncodingUtils {
	
	private static Log log = LogFactory.getLog(EncodingUtils.class);
	
	public static String latinToGBK(String str){
		try {
			return new String(str.getBytes("ISO-8859-1"),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			EncodingUtils.log.error(e.getMessage(), e);
			return str;
		}
	}
	
	public static String GBKTolatin(String str){
		try {
			return new String(str.getBytes("UTF-8"),"ISO-8859-1");
		} catch (UnsupportedEncodingException e) {
			EncodingUtils.log.error(e.getMessage(), e);
			return str;
		}
	}
}
